﻿using EA.BA;
using EA.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Xml;

namespace EAClient
{
    public abstract class WebPage : System.Web.UI.Page
    {
        public static String PATH_IMAGE = "Resources/Product/";
        private Dictionary<String, Object> attributes;
        protected Boolean isLoad = false;
        public Dictionary<String, Object> Attributes
        {
            get
            {
                return attributes;
            }
            set
            {
                value = attributes;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ObjectBA.ConnectionString == null || ObjectBA.ConnectionString.Equals(""))
            {
                ObjectBA.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
            }

            this.isLoad = false;
            attributes = new Dictionary<string, object>();
            if (Request["action"] != null && !Request["action"].Equals(""))
            {
                Type myTypeObj = this.GetType();
                MethodInfo myMethodInfo = myTypeObj.GetMethod(Request["action"]);
                object[] myParam = new object[] { Request, Response };
                myMethodInfo.Invoke(this, myParam);

                if (isLoad)
                {
                    this.Load(sender, e);
                }
            }
            else
            {
                this.Load(sender, e);
            }
        }


        protected abstract void Load(object sender, EventArgs e);

    }
}